using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Globalization;
using System.Collections.Generic;

using ROC.Resources.Library.Data.SQL2005;

namespace MoneyManagerPro.Resources.Repository.Users
{
    internal class GetUserByIdSelectionFactory : ISelectionFactory<System.Int32>, ROC.Resources.Library.Data.Generic.IDbToBusinessEntityNameMapper
    {
        #region ISelectionFactory<int> Members

        public System.Data.SqlClient.SqlCommand ConstructSelectCommand(SqlDatabase db, System.Int32 id)
        {
            SqlCommand command = db.GetStoredProcCommand("GetUserById");
            db.AddInParameter(command, "@Id", SqlDbType.Int, id);

            return command;
        }

        #endregion

        #region IDbToBusinessEntityNameMapper Members

        public string MapDbParameterToBusinessEntityProperty(string dbParameter)
        {

            switch (dbParameter)
            {
                case "@Id":
                    return "Id";
                default:
                    throw new System.ArgumentException(string.Format(CultureInfo.CurrentCulture, ROC.Resources.Library.Data.Generic.GenericResources.InvalidParameterName), dbParameter);
            }
        }

        #endregion
    }
}
